#include "socket.h"
#include "work_thread.h"

#define PATH "/home/ubuntu/code2022/project/usrfile"

int main()
{
    int sockfd = socket_init();
    if (sockfd == -1)
    {
        printf("socket_init err\n");
        exit(1);
    }

    chdir(PATH);
    while (true)
    {
        struct sockaddr_in caddr;
        int len = sizeof(caddr);
        int c = accept(sockfd, (struct sockaddr*)&caddr, &len);
        if (c < 0)
        {
            continue;
        }
        printf("cli connect: (%d)\n", c);
        start_thread(c);
    }

    exit(0);
}
